package com.hamster.crmpre.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hamster.crmpre.pojo.Customer;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Tarry
 * @create 2019/12/25 14:09
 */
@Repository
@Mapper
public interface CustomerMapper extends BaseMapper<Customer> {

    @Select("select id from customer where principal_course_id=#{id} or principal_vip_id=#{id} or developer_id = #{id}")
    List<String> queryCustomerId(@Param("id") String userId);


    @Update("update customer set  balance = balance + #{money}  where id = #{id}")
    void updatePayTheBalance(@Param("id") String id, Double money);

    /**
     * 查询分公司的客户人数
     * @param id
     * @return
     */
    @Select("select count(*) from customer where branch_company_id = #{id}")
    Integer queryCompanyCustomerCount(@Param("id") String id);
}
